

local mt = ac.skill['弹射光球']
mt.temp = '攻击触发'
mt.damage_count = 7
mt.cool = 10
mt.model1 = [[Abilities\Weapons\FarseerMissile\FarseerMissile.mdl]]

function mt:shot_missi(source,dest,params)
    local hero = self.owner
    local start = source:get_launch_point()
    local damage = hero:get('力量') * self.data2
    self.gourp[dest] = true
    local mover = start:launch_missile(dest,self.model1,1200,0,function(mvr)
        hero:create_damage(dest,damage,self)
        self.damage_count = self.damage_count - 1
        if self.damage_count>0 then
            local point = dest:get_point()
            local target = ac.selector('unit'):range(dest,600):is_not(dest):enemy(hero):sorter(function(a,b)
                if self.gourp[a] and self.gourp[b]==nil then
                    return false
                end
                if self.gourp[a]==nil and self.gourp[b] then
                    return true
                end
                local r1 = a:get_point() * point
                local r2 = b:get_point() * point
                return r1 < r2
            end):first()
            if target then
                mvr.need_remove_mover = false
                self:shot_missil(dest,target,{mover = mvr.mover})
            end
        end
    end,params)
end


function mt:on_run(hero,target)
    local temp = self:create_cast()
    temp.gourp = {}
    temp.count = self.data1
    temp:shot_missil(hero,target)
end
